/**
 * 
 */
package org.x.starter4j.jetty.servletserver;

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;

/**
 * @author huangyang@p-an.com 2013年11月10日
 */
public class DemoServletsServer
{
	public static void main(final String[] args) throws Exception
	{
		Server server = new Server(8080);

		ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
		context.setContextPath("/");
		server.setHandler(context);

		// http://localhost:8080/hello
		context.addServlet(new ServletHolder(new HelloServlet()), "/hello");
		// http://localhost:8080/hello/kongxx
		context.addServlet(new ServletHolder(new HelloServlet("hello hgg")), "/hello/hgg");

		// http://localhost:8080/goodbye
		context.addServlet(new ServletHolder(new GoodbyeServlet()), "/goodbye");
		// http://localhost:8080/goodbye/kongxx
		context.addServlet(new ServletHolder(new GoodbyeServlet("Goodbye hgg")), "/goodbye/hgg");

		server.start();
		server.join();
	}

}
